var iconArray=['append','attention2','timeout','done'];
$.get("/event/getlist",null,function(data){
	var array=data;
	$("#event_list_div").empty();
	for(var i=0;i<array.length;i++){

        var iconName=iconArray[array[i].stauts];
        var points=array[i].point;
        var days=array[i].deadline;
        var curDay = new Date();
        var secs=array[i].deadline-curDay.getTime();
        var lefttime=parseInt(secs/(3600000*24))+" days";
        var title=array[i].title;
        var oneEvent="<div class='event_div' id='"+array[i].id+"'><div class='event_p1'> <img class='event_icon' src='image/icon/"+iconName+".ico'></img></div><div class='event_p2'> <label class='event_text'>"+title+"</label></div><div class='event_p3'> <label class='event_text'>"+lefttime+"</label></div><div class='event_p4'><label class='event_text'>"+points+"</label></div><div class='event_p5'><label class='event_handle'><label class='complete' >完成</label> | <label class='handle'>处理</label> </label></div></div>";
        $("#event_list_div").append(oneEvent);
        $("#"+array[i].id+" .complete").click(function(){

        	var Obj=new Object();
        	// alert($(this).parents('.event_div').attr('id'));
        	Obj.id=$(this).parents('.event_div').attr('id');
        	$(this).parents('.event_div').children('.event_p1').children('.event_icon').attr("src","image/icon/done.ico");
        	var newIcon=$(this).parents('.event_div').children('.event_p1').children('.event_icon').attr("src");

    

            $.post("/event/complete",Obj,function(){
            });
        });
	}
});